package com.raise.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yunji.htmltoimage.PhantomjsMain;
import com.yunji.htmltoimage.entity.Phantomjs;
import com.yunji.htmltoimage.entity.TransformResult;

@Controller
public class TestAction{
	@ResponseBody
    @RequestMapping(value = "/transform.html")
    public Object test(HttpServletRequest request) {
		Phantomjs phantomjs = new Phantomjs();
        phantomjs.setHtmlUrl("http://m.yunjiweidian.com/yunjibuyer/subject/index/50445");
        phantomjs.setTimeout(5000L);

        
        TransformResult result = PhantomjsMain.transform(phantomjs);
        System.out.println("转换结果："+result.getResult());
        System.out.println("输出图片名称："+result.getImageName());
        System.out.println("输出图片目录："+result.getImagePath());
        System.out.println("错误信息："+result.getMessage());
        System.out.println("---");

        return result;
    }
	@ResponseBody
    @RequestMapping(value = "/test.html")
    public Object test2(HttpServletRequest request) {
		
        return "ddd";
    }
	@ResponseBody
    @RequestMapping(value = "/test2dddd.html")
    public Object test222(HttpServletRequest request) {
		
        return "hello world1";
    }

    @ResponseBody
    @RequestMapping(value = "/h1i.html")
    public Object hi(HttpServletRequest request) {

        return "hi";
    }
    @ResponseBody
    @RequestMapping(value = "/")
    public Object index(HttpServletRequest request) {

        return "this is index page";
    }
    @ResponseBody
    @RequestMapping(value = "/index.html")
    public Object _index(HttpServletRequest request) {

        return "this is index page";
    }
}
